package cn.yt.hospital.config;

import cn.yt.hospital.handler.LoginHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 杨涛
 * @date 2023/3/1 14:33
 */
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginHandler loginHandler;
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginHandler);
        //配置拦截器 需要拦截的
        interceptorRegistration.addPathPatterns("/**")
                .excludePathPatterns("/hospital/userses/login","/hospital/userses/doLogin","/**/*.js","/**/*.css");
        //不需要拦截的 excludePathPatterns
    }
}
